import { History, Location } from "history-with-query"
import { IRoute, IRouteComponentProps } from "umi"

export interface RouteItem extends IRoute {
  //排序字段
  sort?: number
  title?: string
  routes?: RouteItem[]
  //图标字段
  icon?: string
  //是否显示在左侧菜单
  menu?: boolean
}

export interface RenderOpts {
  routes: RouteItem[]
  plugin: { hooks: RouteHooks; validKeys: string[] }
  history: History
  dynamicImport: boolean
  rootElement: string
  defaultTitle: string
}

export interface RouteHooks {
  modifyClientRenderOpts: any
  patchRoutes: any
  render: any
  onRouteChange: any
  rootContainer: any
}

export interface rootContainerParams {
  key: string
  ref: any
  props: {
    history: History
    routes: RouteItem[]
    plugin: { hooks: RouteHooks; validKeys: string[] }
    defaultTitle: string
  }
}

export interface RouteChangeParams {
  routes: RouteItem[]
  matchedRoutes: MatchedRoute[]
  location: Location
  action: string
}

export interface MatchedRoute {
  route: RouteItem
  match: RouteMatch
}
export interface RouteMatch {
  path: string
  url: string
  isExact: boolean
  params: any
}
